<?php

abstract class DBU_Db_Adapters_Abstract {

	public function listTables() {
		$return = array();
		$result = $this->execute('SHOW TABLES');

		if ($this->numRows($result)) {
			while ($row = $this->fetchAssoc($result)) {
				$return[] = $row;
			}
		}
		return $return;
	}

   /**
	* Executes SQL query
	*
	* @param string $sql
	* @return result ID
	*/
	public function execute($sql) {
		$query = $this->query($sql);

		if ($query !== false) {
            $message = 'SQL [' . $sql . ']['.$this->affectedRows().'][INFO: '.$this->info().']';
            DBU_Logger::instance()->add($message);

			return $query;
		} else {
            $message = 'SQL [' . $sql . '][ERROR: '.$this->error().']';
			throw new DBU_Db_Exception($message);
		}
	}
}